package cn.hx.mall.order.service.impl;

import cn.hx.mall.order.dao.OrderSettingDao;
import cn.hx.mall.order.entity.OrderSetting;
import cn.hx.mall.order.service.OrderSettingService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 订单设置表(OrderSetting)表服务实现类
 *
 * @author makejava
 * @since 2022-11-02 17:57:21
 */
@Service("orderSettingService")
public class OrderSettingServiceImpl implements OrderSettingService {
    @Resource
    private OrderSettingDao orderSettingDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public OrderSetting queryById(Long id) {
        return this.orderSettingDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<OrderSetting> queryAllByLimit(int offset, int limit) {
        return this.orderSettingDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param orderSetting 实例对象
     * @return 实例对象
     */
    @Override
    public OrderSetting insert(OrderSetting orderSetting) {
        this.orderSettingDao.insert(orderSetting);
        return orderSetting;
    }

    /**
     * 修改数据
     *
     * @param orderSetting 实例对象
     * @return 实例对象
     */
    @Override
    public OrderSetting update(OrderSetting orderSetting) {
        this.orderSettingDao.update(orderSetting);
        return this.queryById(orderSetting.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.orderSettingDao.deleteById(id) > 0;
    }

    @Override
    public List<OrderSetting> queryAll(OrderSetting orderSetting) {
        return orderSettingDao.queryAll(orderSetting);
    }
}